package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BasWatergate;
import com.ruoyi.base.service.IBasWatergateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 闸口Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/base/watergate")
public class BasWatergateController extends BaseController
{
    @Autowired
    private IBasWatergateService basWatergateService;

    /**
     * 查询闸口列表
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasWatergate basWatergate)
    {
        startPage();
        List<BasWatergate> list = basWatergateService.selectBasWatergateList(basWatergate);
        return getDataTable(list);
    }

    /**
     * 导出闸口列表
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:export')")
//    @Log(title = "闸口", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasWatergate basWatergate)
    {
        List<BasWatergate> list = basWatergateService.selectBasWatergateList(basWatergate);
        ExcelUtil<BasWatergate> util = new ExcelUtil<BasWatergate>(BasWatergate.class);
        util.exportExcel(response, list, "闸口数据");
    }

    /**
     * 获取闸口详细信息
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:query')")
    @GetMapping(value = "/getinfo/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(basWatergateService.selectBasWatergateByID(ID));
    }

    /**
     * 新增闸口
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:add')")
//    @Log(title = "闸口", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BasWatergate basWatergate)
    {
        return toAjax(basWatergateService.insertBasWatergate(basWatergate));
    }

    /**
     * 修改闸口
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:edit')")
//    @Log(title = "闸口", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BasWatergate basWatergate)
    {
        return toAjax(basWatergateService.updateBasWatergate(basWatergate));
    }

    /**
     * 删除闸口
     */
//    @PreAuthorize("@ss.hasPermi('base:watergate:remove')")
//    @Log(title = "闸口", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(basWatergateService.deleteBasWatergateByIDs(IDs));
    }
}
